home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / d_d / caltech / inbound / mcm / personsr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-22  |  3.7 KB  |  166 lines

  1. /* Personality module for MCM 1.1e */
  2.  
  3. /* Modify the routines in this module to suit your needs, but make */
  4. /* sure that you include all of the listed subroutines.  If you send */
  5. /* me (msawyer@mael.soest.hawaii.edu) your personality files, I will */
  6. /* try to get as many included in the distribution as possible, but */
  7. /* make no promises.  You may redistribute modified versions of this */
  8. /* file. */
  9.  
  10. /* This is a _SAMPLE_ Shadowrun style personality.  Because I do not */
  11. /* know the mechanics of Shadowrun, all that is included is a short */
  12. /* routine to handle the dice-rolling system used there. */
  13.  
  14. #include "mcm.h"
  15.  
  16. int shadowroll;
  17.  
  18.  /* General purpose initialization routine.  Called as soon as the */
  19.  /* port is initialized. */
  20.  
  21. void per_init()
  22. {
  23. }
  24.  
  25.  /* Define a new signal processor for SIG_USR2.  There really isn't */
  26.  /* that much need for this, but it is here in case you want it. */
  27.  
  28. void per_sig2()
  29. {
  30. }
  31.  
  32.  /* Define a routine to be run once per each time step */
  33.  
  34. void per_timestep()
  35. {
  36. }
  37.  
  38.  /* Define a pre-processor for the tell() call.  You may modify the */
  39.  /* system and/or text fields, and should return TRUE if you want the */
  40.  /* tell() to continue, or FALSE to fall out. */
  41.  
  42. int per_tell(msgfrom, msgto, system, text)
  43. int msgfrom, msgto;
  44. char *system, *text;
  45. {
  46.   return (TRUE);
  47. }
  48.  
  49.  /* Define a pre-processor for the process() call.  You may call any */
  50.  /* mcm or personality subroutines here and/or modify the command */
  51.  /* variable.  Again, returning TRUE allows the process() to continue */
  52.  
  53. int per_process(msgfrom, command)
  54. int msgfrom;
  55. char *command;
  56. {
  57.   return (TRUE);
  58. }
  59.  
  60.  /* Define a special processor to be run after each successful login */
  61.  /* attempt. */
  62.  
  63. void per_login(msgfrom)
  64. int msgfrom;
  65. {
  66. }
  67.  
  68.  /* Define a short routine to document any additional * and / commands */
  69.  /* added by the per_process() call.  TRUE continues with the normal */
  70.  /* help messages */
  71.  
  72. int per_slashhelp(msgfrom)
  73. int msgfrom;
  74. {
  75.   return (TRUE);
  76. }
  77.  
  78. int per_starhelp(msgfrom)
  79. int msgfrom;
  80. {
  81.   return (TRUE);
  82. }
  83.  
  84.  /* Now get additional mode help text */
  85.  
  86. int per_modehelp(msgfrom)
  87. int msgfrom;
  88. {
  89.   return (TRUE);
  90. }
  91.  
  92.  /* Define a pre-processor for the mode (*M) commands.  Again, you may */
  93.  /* modify the command field, and returning TRUE runs the normal mode */
  94.  /* commands on the modified text */
  95.  
  96. int per_mode(msgfrom, command)
  97. int msgfrom;
  98. char *command;
  99. {
  100.   return (TRUE);
  101. }
  102.  
  103.  /* Define a set of processes to be called before and after rolling */
  104.  /* the dice.  You may, in per_preroll() evaluate a modified roll */
  105.  /* command (ie: /RH for roll to hit), modifying the command text to a */
  106.  /* appropriate roll command (/Rd20).  You may then, in per_postroll() */
  107.  /* modify the output string to a more appropriate message (ie: Hit */
  108.  /* AC3).  If either routine returns FALSE, roll() will terminate, */
  109.  /* assuming that the personality mode took care of the rest. */
  110.  
  111. int per_preroll(job, command)
  112. int job;
  113. char *command;
  114. {
  115.   return(TRUE);
  116. }
  117.  
  118. int per_postroll(pubroll, job, res_text, res_val, number, sides, rolls)
  119. int pubroll, job, res_val, number, sides;
  120. char *res_text;
  121. int rolls[20];
  122. {
  123.   int i, anyhits;
  124.   char newstring[80];
  125.  
  126.   anyhits=1;
  127.   while (anyhits==1)
  128.   {
  129.     anyhits=0;
  130.     for (i=0;i<number;i++)
  131.     {
  132.       if (rolls[i]==sides)
  133.       {
  134.     rolls[i]=lrand48()%sides;
  135.     rolls[i]++;
  136.     anyhits=1;
  137.       }
  138.       else
  139.     rolls[i]=0;
  140.     }
  141.     if (anyhits==1)
  142.     {
  143.       strcat (res_text," [");
  144.       for (i=0;i<number;i++)
  145.       {
  146.     if (rolls[i]!=0)
  147.     {
  148.       sprintf (newstring,"+%d",rolls[i]);
  149.       strcat (res_text,newstring);
  150.       res_val+=rolls[i];
  151.     }
  152.       }
  153.       sprintf (newstring,"]=%d",res_val);
  154.       strcat (res_text,newstring);
  155.     }
  156.   }
  157.   return (TRUE);
  158. }
  159.  
  160.  /* And finally a special process to be run when a user logs out. */
  161. void per_logout(msgfrom)
  162. int msgfrom;
  163. {
  164. }
  165.  
  166.